

import com.yundou.www.wrpc.core.build.ServerBuilder;
import com.yundou.www.wrpc.core.factory.DefaultWrpcFactory;
import com.yundou.www.wrpc.core.net.ServiceProxy;
import com.yundou.www.wrpc.core.net.WRpcRequest;
import com.yundou.www.wrpc.core.net.WRpcResponse;

import java.util.Arrays;


/**
 * @author wangweiwei
 * @since 2021/7/15
 */
public class UserDEmo {

    public static void main(String[] args) {

//        Enhancer enhancer = new Enhancer();
//        enhancer.setSuperclass(UserService.class);
//        enhancer.setCallback((MethodInterceptor) (o, method, objects, methodProxy) -> {
//            Class<?> returnType = method.getReturnType();
//            System.out.println(returnType);
//            String methodName = method.getName();
//            switch (methodName){
//                case "saveUser" :
//                    System.out.println("我做保存");
//                    return null;
//                case "getAllUserName":
//                    return Collections.singletonList("dadas");
//                default:
//                    return null;
//            }
////            System.out.println(method.getName());
////            Object o1 = methodProxy.invokeSuper(o, objects);
////            return o1;
//        });
//
//        UserService user = (UserService) enhancer.create();
//        user.saveUser("adasd");
//        System.out.println(user.getAllUserName());


//        List<Class> classes = ClassLoadUtil.find("com.yundou.www.wrpc.core", WRpcClient.class);
//
//        System.out.println(classes);

        new ServerBuilder(new DefaultWrpcFactory()).loadServer("com.yundou.www.wrpc.core");

//        WRpcRequest request = new WRpcRequest();
//        request.setInterfaceName("com.yundou.www.wrpc.core.face.UserService");
//        request.setMethodName("getAllUserName");
//        request.setParams(new Object[0]);
//        WRpcResponse response = ServiceProxy.doExecuteRequest(request);
//        System.out.println(response.getCode());
//        System.out.println(response.getResult());


//        String asad = "{\"checkSession\":1}{\"id\":2,\"interfaceName\":\"com.yundou.www.wrpc.core.face.UserService\",\"methodName\":\"getAllUserName\",\"params\":[],\"version\":1}";
//        String[] split = asad.split("/}");
//        System.out.println(Arrays.toString(split));


    }
}
